<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
	<c:set var="emp" value="${sessionScope.user}"/>
	<c:forEach var="ro" items="${emp.roles}">
		<c:forEach var="fu" items="${ro.functionAll}">
			<c:if test="${fu.code=='security-edit'}">
				<c:set var="roleEdit" value="true"/>
			</c:if>
		</c:forEach>
	</c:forEach>
	
<div class="mailbox row">
	<div class="col-xs-12">
		<div class="box box-solid">
			<div class="box-body">
				<div class="row">
					<div class="col-md-2">
						<!-- --------- 分类导航 start------------- -->
						<div style="margin-top: 15px;">
							<ul class="nav nav-pills nav-stacked">
								<li class="header">角色管理</li>
								<c:forEach var="ro" items="${emp.roles}">
									<c:forEach var="fu" items="${ro.functionAll}">
										<c:if test="${fu.code=='security-list'}">
											<li class="active"><a href="#"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
										</c:if>
										<c:if test="${fu.code=='security-add'}">
											<li id="role_add"><a href="#"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
										</c:if>	
									</c:forEach>
								</c:forEach>
								
								
							</ul>
						</div>
						<!-- --------- 分类导航 end------------- -->
					</div>
					<!-- /.col (LEFT) -->
					<div class="col-md-10">
						<!-- /.row -->
						<!-- 	1.table-responsive放在table的上一级
								2.td里的内容增多
								  才会出现滚动条！ -->
						<div class="table-responsive">
							<!-- --------- 列表 start------------- -->
							<table class="table table-striped">
								<thead>
									<tr>
										<th>角色名</th><th>操作</th>
									</tr>
								</thead>
								<tbody id="roletbody">
									<c:forEach var="role" items="${requestScope.roleList}">
										<tr>
											<td>${role.name}</td>
											<td>
												<c:if test="${roleEdit==true}">
													<button class="btn btn-primary btn_roleedit" data-id="${role.id}">编辑</button>
												</c:if>
												<c:if test="${roleEdit!=true}">
													无	
												</c:if>
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
							<!-- --------- 列表 end------------- -->
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /.col (RIGHT) -->
				</div>
				<!-- /.row -->
			</div>
			<!-- /.box-body -->
			<div class="box-footer clearfix">
				<div class="pull-right">
					<small>显示<span>第1页</span>共1页</small>
						<a href="#" class="btn btn-xs btn-primary">
							<i class="fa fa-caret-left"></i>
						</a>
						<a href="#" class="btn btn-xs btn-primary">
							<i class="fa fa-caret-right"></i>
						</a>
				</div>
			</div>
			<!-- box-footer -->
		</div>
		<!-- /.box -->
	</div>
	<!-- /.col (MAIN) -->
</div>
<!-- MAILBOX END -->
<div id="roleEdit" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" id="btn_roleClose" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="roleTitle">添加角色</h4>
      </div>
      <div class="modal-body">
        <form id="roleForm" role="form" action="" method="post" class="form-inline">
        	<div style="margin-bottom: 20px;">
				<label>角色名:</label>&nbsp;&nbsp;
				<input name="name" type="text" id="rolename"/>
				<input type="hidden" name="roleId" id="roleId">
			</div>
			<c:forEach var="fu" items="${sessionScope.functions}">
				<fieldset style="margin-bottom: 30px;">
	            	<legend style="font-size: 15px;">
	            		<input id="${fu.code}" type="checkbox" class="role-info ck_role" name="functionId" value="${fu.id}">&nbsp;&nbsp;
						<label for="${fu.code}">${fu.name}</label>
	            	</legend>
	            	<c:forEach var="child" items="${fu.children}">
	            		<c:if test="${empty child.children}">
	            			<div class="form-group" style="margin-left: 10px">
							    <input id="${child.code}" type="checkbox" class="role-info ck_role" name="functionId" value="${child.id}">&nbsp;&nbsp;
							    <label for="${child.code}">${child.name}</label>
							 </div>
	            		</c:if>
	            		
	            		
						 <c:if test="${not empty child.children}">
						 	<br/>
						 	<div class="form-group" style="margin-left: 10px">
							    <input id="${child.code}" type="checkbox" class="role-info ck_role" name="functionId" value="${child.id}">&nbsp;&nbsp;
							    <label for="${child.code}">${child.name}</label>
							 </div>
						 	<fieldset style="margin-bottom: 10px;margin-left:40px;">
				            	<legend style="font-size: 15px;"></legend>
				            	<c:forEach var="secondChild" items="${child.children}">
				            		<c:if test="${empty secondChild.children}">
				            			<div class="form-group" style="margin-left: 10px">
										    <input id="${secondChild.code }" type="checkbox" class="role-info ck_role" name="functionId" value="${secondChild.id}">&nbsp;&nbsp;
										    <label for="${secondChild.code}">${secondChild.name}</label>
										 </div>	
				            		</c:if>
				            			
									 <c:if test="${not empty secondChild.children}">
									 	<br/>
									 	<div class="form-group" style="margin-left: 10px">
										    <input id="${secondChild.code }" type="checkbox" class="role-info ck_role" name="functionId" value="${secondChild.id}">&nbsp;&nbsp;
										    <label for="${secondChild.code}">${secondChild.name}</label>
										 </div>	
									 	<fieldset style="margin-bottom: 10px;margin-left:40px;">
							            	<legend style="font-size: 15px;"></legend>
							            	<c:forEach var="thirdChild" items="${secondChild.children}">
							            		<div class="form-group" style="margin-left: 10px">
												    <input id="${thirdChild.code}" type="checkbox" class="role-info ck_role" name="functionId" value="${thirdChild.id}">&nbsp;&nbsp;
												    <label for="${thirdChild.code}">${thirdChild.name}</label>
												 </div>
							            	</c:forEach>
							            </fieldset>
									 </c:if>
				            	</c:forEach>
				            </fieldset>
						 </c:if>
	            	</c:forEach>
	            	
	            </fieldset>
			</c:forEach>
         </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" id="role-close">关闭</button>
        <button type="button" class="btn btn-primary" id="role-save">保存</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->